Skip to content

Reduce AI deadlocks#284

Open
Asdow wants to merge 86 commits intomasterfrom
decideaction
Open

Reduce AI deadlocks#284
Asdow wants to merge 86 commits intomasterfrom
decideaction

Conversation

@Asdow
Copy link
Copy Markdown
Contributor

@Asdow Asdow commented Feb 11, 2024

Quite a bit of changes done, with mostly trying to fix the passive AI and reduce AI deadlocks. Actual AI behavior should be mostly the same as before.

Also some additional AI logging

Asdow added 30 commits August 16, 2023 23:07
Logging AI decisions shows that this conditional would constantly cancel AI actions during regular gameplay. A special case like this should not affect normal AI routines and I'd rather disable this for now to prevent it from masking other problems with AI decisions.
Clutters logs and slows down game less when logging is on.
!AimingGun(pSoldier) would always evaluate to true and there are no hits to CrowDecideAction in the entire solution even in commented out code
Originally placed in DecideAction(green/yellow/red/black) functions separately
Canceling current AI actions at the start of soldier's turn prevents a lot of ai deadlocks. The status RED & BLACK actions are supposed re-evaluate the situation every turn anyways
We can't do anything with negative action points either.
aiData.bRTPCombat is never initialized and is always 0 when valid values should be

#define RTP_COMBAT_AGGRESSIVE		1
#define RTP_COMBAT_CONSERVE			2
#define RTP_COMBAT_REFRAIN			3
It's already handled before a call to this function, and TurnBasedHandleNPCAI() is only called when pSoldier's action is AI_ACTION_NONE
Less clutter in the AI logs if, for example one is only interested in BLACK status decisions
Several actions would sometimes get stuck in a forever loop, where they would not be executed, since no proper path for executing the actions is found.

Originally TurnBasedHandleNPCAI() would only be called if aidata.bAction was AI_ACTION_NONE.
Now we'll call it if an action is not already in progress, and will be executed if the action is affordable.
Asdow added 30 commits January 19, 2026 22:05
* Add optional parameter to ignore search range
* Removes the need to constantly check for fCivilian, ARMED_VEHICLE, ENEMY_ROBOT etc inside DecideAction
* Move AI decision checks into their own functions, such as DecideActionRadioRedAlert
* Add new entry to ActionType. AI_ACTION_INVALID signals that no valid action was found when a function returns, or no valid action is possible
* Do a weighted random selection for choosing target under DecideActionBlackSoldier
distanceInCellCoords will return the distance between pSoldier and closest known opponent. We're often calculating same range after the call using PythSpacesAway and this way it's no longer necessary in most cases.
This was absolutely clogging Debug build when compressing time
SoldierID works without it thanks to operator overload
Possibly wear gasmask if soldier sees tear or mustard gas
Create Scuba fins when in deep water for elites
* Drink canteen
* Jump through window
* Use explosives
* Use wirecutters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant